
<script lang="ts" setup>
import ecologyScroll from './components/ecologyScroll.vue'
import supportItemVue from "@/components/supportItem.vue";
import ecologyCarousel from './components/ecologyCarousel.vue';
import { getProductsDetail } from '@/network/api'
import { ref, reactive, watch, onMounted, inject } from 'vue'
import { useRoute } from "vue-router";

let ecologyDetailInfo = reactive({
    file_datas: [] as any,
    series_products: [] as any,
    detail: {} as any
})

const productReveal = ref([]) as any

const ecologyId = ref() as any
const Route = useRoute();

if (Route.query.id) ecologyId.value = Route.query.id

watch(() => Route.query, (newValue) => {
    ecologyId.value = newValue.id
    if (ecologyId.value) {
        GetEcologyDetail()
    }
})


const GetEcologyDetail = async () => {
    const { data: ecologyData } = await getProductsDetail({ products_id: ecologyId.value })
    ecologyDetailInfo.detail = ecologyData?.detail
    ecologyDetailInfo.file_datas = ecologyData?.file_datas
    ecologyDetailInfo.series_products = ecologyData?.series_products
    ecologyDetailInfo?.detail?.images.forEach((item: any) => {
        productReveal.value.push({ ['cover_image']: item, ['video_url']: '' })
    })
}

const myFn = inject<any>("open",ecologyId.value)

onMounted(() => {
    GetEcologyDetail()
})

</script>

<template>
    <div class="content" style="margin:0 auto">
        <div class="breadcrumb">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: 'Ecology' }">生态平台</el-breadcrumb-item>
                <el-breadcrumb-item>{{ ecologyDetailInfo.detail.name }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="ecology_detail">
            <el-row justify="space-between">
                <el-col :span="12" :xs="24">
                    <div class="flex">
                        <el-image class="ecology_detail_image" :src="ecologyDetailInfo.detail.cover_image"></el-image>
                        <div>
                            <div class="ecology_detail_name">{{ ecologyDetailInfo.detail.name }}</div>
                            <div class="ecology_detail_company new_info">{{ ecologyDetailInfo.detail.supplier_name }}</div>
                            <div class="ecology_detail_tag">
                                <el-tag v-for="tagItem in ecologyDetailInfo.detail.category_name" :key="tagItem"
                                    effect="plain" round>
                                    {{ tagItem }}
                                </el-tag>
                            </div>
                        </div>
                    </div>
                    <div class="ecology_detail_des_box new_info">
                        <div v-for="(item, index) in ecologyDetailInfo.detail.intro" :key="index"
                            class="contentText ecology_detail_des">
                            ● {{ item }}
                        </div>
                    </div>
                    <div class="ecology_detail_btn">
                        <el-button color="#064DD6" size="large" round @click="myFn">立即咨询</el-button>
                    </div>
                </el-col>
                <el-col :span="3" :xs="24">
                    <div class="flex flex_column justify_end align_center">
                        <el-image class="ecology_detail_qrCode" :src="ecologyDetailInfo?.detail?.learn_more"></el-image>
                        <div class="flex justify_center ecology_detail_qrCode_text">扫码体验</div>
                    </div>
                </el-col>
            </el-row>
        </div>
    </div>
    <div class="bgfff" v-if="ecologyDetailInfo.detail.detail_intro">
        <div class="content bgfff" style="margin: 0 auto">
            <div class="midContent">
                <div class="overview">
                    <div class="overviewTitle bigTitle">产品介绍</div>
                    <div class="overviewText">
                        <div class="contentText" v-for="(item, index) in ecologyDetailInfo.detail.detail_intro" :key="index">{{ item }}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="content" style="margin: 0 auto">
        <div class="ecology_scroll_box">
            <ecology-scroll :scrollData="ecologyDetailInfo.detail.images"></ecology-scroll>
        </div>
    </div>
    <div class="bgfff">
        <div class="content " style="margin: 0 auto">
            <supportItemVue :supportData="ecologyDetailInfo.file_datas"></supportItemVue>
        </div>
    </div>
    <!-- <div class="ecology_carousel_box content" style="margin:0 auto">
        <ecologyCarousel></ecologyCarousel>
    </div> -->
</template>

<style lang="scss" scoped>
@import url("@/assets/css/content.css");

.breadcrumb {
    border-bottom: 2px solid $auxiliaryColor3;
    padding: 0 0 16px 0;
    margin-bottom: 40px;
}

.ecology_detail_image {
    width: 100px;
    height: 100px;
    border-radius: 10px;
}

.ecology_detail_name {
    font-size: 28px;
    color: #172E59;
    font-family: alibabapuhuitiRegular;
    margin-left: 22px;
}

.ecology_detail_company {
    margin: 8px 0 11px 22px;
}

.ecology_detail_tag {
    margin-left: 22px;

    :deep(.el-tag) {
        color: #064DD6;
        border-color: #064DD6;
        margin-right: 10px;
        padding: 0 15px;
    }
}

.ecology_detail_des_box {
    margin-top: 40px;
    font-size: 18px;
    color: #172E59;
    font-family: alibabapuhuitiRegular;

    .ecology_detail_des {
        margin-bottom: 20px;
    }
}

.ecology_detail_btn {
    margin-top: 60px;
}

.ecology_detail_qrCode {
    width: 167px;
    height: 167px;
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 8px;
    margin: 0 auto
}

.ecology_detail_qrCode_text {
    margin-top: 10px;
    font-size: 21px;
    color: #172E59;
    font-family: alibabapuhuitiRegular;
}


.overviewText {
    width: 72%;
    text-align: center;
    margin: 0 auto;

    img {
        width: 100%;
    }

    :deep(table) {
        max-width: 100% !important;
        margin: 0 auto;
    }
}

.ecology_scroll_box {
    width: 72%;
    margin: 0 auto;
}

/* .ecology_carousel_box{
    padding: 40px 0;
} */


.midContent {
    // width: 1440px;
    margin: auto;
}

.overview {
    width: 60%;
    margin: 0 auto;
    text-align: center;
    padding-bottom: 40px;

    .overviewTitle {
        // font-weight: bold;
        padding: 60px 0 40px 0;
    }

    .overviewText {
        text-align: center;

        div {
            margin-bottom: 20px;
        }
    }
}

@media screen and (max-width: 450px) {
    .overviewText {
        width: 100%;

        img {
            width: 100%;
        }
    }

    .ecology_scroll_box {
        width: 100%;
    }

    .ecology_detail_qrCode {
        margin-top: 20px;
    }

    .ecology_detail_btn {
        margin-top: 20px;
    }

    .midContent {
        width: 100%;
    }

    .overview {
        width: 100%;

        .overviewTitle {
            text-align: left;
            padding: 40px 0 20px 0;
            // padding-left: 10px;
        }
    }
}
</style>